package com.param_validate_demo.annotation;

import com.param_validate_demo.validator.EnumValidator;

import javax.validation.Constraint;
import javax.validation.Payload;
import java.lang.annotation.*;

@Documented
@Constraint(validatedBy = EnumValidator.class)
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.FIELD})
public @interface EnumValidate {

    /**
     * 是否必填，默认必填
     */
    boolean required() default true;

    Class<? extends Enum<?>> enumClass();

    /**
     * 必要参数，否则报错
     */
    String message() default "";

    /**
     * 必要参数，否则报错
     * javax.validation.ConstraintDefinitionException: HV000074: com.param_validate_demo.annotation.EnumValidate contains Constraint annotation, but does not contain a groups parameter.
     */
    Class<?>[] groups() default { };

    /**
     * 必要参数，否则报错
     */
    Class<? extends Payload>[] payload() default {};

}